<?php include 'application/views/header.php' ?>
<h4 class="page-title">Danh sách hình ảnh</h4>
<div class="toolbar-set">
    <input type="button" class="btnAdd" value="Thêm hình ảnh" />
</div>
<table width="100%" class="list list-picture">
    <tr>
        <th>STT</th>
        <th>Tên hình ảnh</th>
        <th>Tiêu đề hình ảnh</th>
        <th>Hình</th>
        <th>Hiển thị</th>
        <th>Thao tác</th>
    </tr>
    <?php $index = 1 ?>
    <?php foreach($Pictures as $picture): ?>
    <tr>
       <td><?php echo $index++ ?></td>
       <td><?php echo $picture['PictureName'] ?></td>
       <td><?php echo $picture['PictureTitle'] ?></td>
       <td><img width="50" src="<?php echo $this->config->item('base_download') ?>/pictures/<?php echo $picture['PictureLink'] ?>" /></td>
       <td><?php echo ($picture['Visible'] ? 'Hiện' : 'Ẩn')?></td>
       <td>
            <a href="<?php echo base_url() ?>picture/edit/<?php echo $picture['PictureId'] ?>.html">
                <div class="actEdit">Edit</div>
            </a>
            <a href="#">
                <div class="actDelete" pictureId="<?php echo $picture['PictureId'] ?>">Xóa</div>
            </a>
       </td>
    </tr>
    <?php endforeach; ?>
</table>
<!-- pagination -->
<div class="pagination-set">
    <?php echo $this->pagination->create_links() ?>
</div>
<div class="toolbar-set">
    <input type="button" class="btnAdd" value="Thêm hình ảnh" />
</div>
<?php include 'application/views/footer.php' ?>

<script>
$('.btnAdd').click(function(){
    window.location.href = '<?php echo base_url() ?>picture/add.html'; 
});
$('.actDelete').click(function(){
    var pictureId = $(this).attr('pictureId');
    if(confirm("Bạn có muốn xóa không?")){
        window.location.href = '<?php echo base_url() ?>picture/delete/'+pictureId;
    }
    return false;
})
</script>